﻿@model PokerLife.Models.SYS.UserViewModel
@{
    ViewBag.Title = "AddEdit";
    Layout = "~/Views/Shared/_LayoutBlank.cshtml";
}

<div>

@*    @Html.AntiForgeryToken()*@
 @*   @Html.ValidationSummary(true)*@

    @Html.HiddenFor(p=>p.IDSys)

    <div class="f_row">
        <div class="f_lable">
            @Html.LabelFor(p => p.UserName)
        </div>
        <div class="f_editor">
            @Html.TextBoxFor(p => p.UserName, new { style = "width:300px;height:22px" })
            @Html.ValidationMessageFor(p => p.UserName)
        </div>
    </div>

    <div class="f_row">
        <div class="f_lable">
            @Html.LabelFor(p => p.Password)
        </div>
        <div class="f_editor">
            @Html.PasswordFor(p => p.Password, new { style = "width:300px;height:22px" })
            @Html.ValidationMessageFor(p => p.Password)
        </div>
    </div>

    <div class="f_row">
        <div class="f_lable">
            @Html.LabelFor(p => p.Note)
        </div>
        <div class="f_editor">
            @Html.TextAreaFor(p => p.Note, new { style = "width:300px;height:44px" })
        </div>
    </div>

<div class="f_row">
        <div class="f_lable">
            @Html.LabelFor(p => p.IsActived)
        </div>
        <div class="f_editor">
            @Html.CheckBoxFor(p => p.IsActived)
        </div>
    </div>

<div class="f_row">
        <div style="float:right">
            <input id="btnSave" class="k-button toolbarbuttonsize" type="button" value="Save" />
            <input id="btnExit" class="k-button toolbarbuttonsize" type="button" value="Exit" />
        </div>
    </div>
</div>

<style>
    .f_row {
        clear: both;
        float: left;
        width: 90%;
        padding-left: 20px;
        padding-top: 5px;

    }

    .f_lable {
        float: left;
        width: 25%;
    }

    .f_editor {
        float: left;
        width: 75%;
    }
    #IsActived {
       margin-left:0px;
    }
    
</style>

<script>

    $("#btnSave").click(function (e) {
        e.preventDefault();

        var User = {};
        User.IDSys = $("#IDSys").val();
        User.UserName = $("#UserName").val();
        User.Password = $("#Password").val();
        User.Note = $("#Note").val();
        User.IsActived = $("#IsActived").val();

        $.ajax({
            url: '@Url.Content("~/User/AddEdit")',
            type: 'POST',
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(User),
            traditional: true,
            success: function (result) {
                kendo.ui.ExtAlertDialog.show({ title: "Thông báo!", message: result.Message });
                //window.parent.$("#window").data("kendoWindow").close();
            },
            error: function (event, request, settings) {
                alert(settings);
            }
        });
    });

    $("#btnExit").click(function (e) {
        e.preventDefault();
        window.parent.$("#window").data("kendoWindow").close();
    });

</script>

@Scripts.Render("~/bundles/jqueryval")